from typing import Optional

from sqlalchemy import DateTime, Integer, PrimaryKeyConstraint, REAL, String
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
import datetime

class Base(DeclarativeBase):
    pass


class Facilities(Base):
    __tablename__ = 'facilities'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='facilities_pkey'),
    )

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    facility_code: Mapped[str] = mapped_column(String(50), comment='操作柜编号')
    model: Mapped[Optional[str]] = mapped_column(String(100), comment='型号')
    power: Mapped[Optional[float]] = mapped_column(REAL, comment='功率')
    current: Mapped[Optional[float]] = mapped_column(REAL, comment='电流')
    name: Mapped[Optional[str]] = mapped_column(String(100), comment='名称')
    start_date: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='启用日期')
    scrap_date: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='报废日期')
